import os
import pandas as pd

def simple_csv_generation(data_path="food11/versions/1/validation"):
    training_path = data_path
    data = []

    for img_file in os.listdir(training_path):
        if img_file.endswith('.jpg') and '_' in img_file:
            class_label = int(img_file.split('_')[0])
            img_path = os.path.join(training_path, img_file)
            data.append({'image_path': img_path, 'label': class_label})
    df = pd.DataFrame(data)

    df.to_csv('food11_simple_v.csv', index=False)
    print(f"包含 {len(df)} 条记录")
    return df

if __name__ == "__main__":
    simple_csv_generation()